home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / PUTTEXT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  884 b   |  32 lines

  1. /* puttext.c --- p 890 --- */
  2. #include <alloc.h>
  3. #include <conio.h>
  4. main()
  5. {
  6.     int i, bufsize, top = 1, left = 1, right = 80, bottom = 5;
  7.     char *tbuffer;
  8.     clrscr();
  9.     gotoxy(1, 1);
  10.     for(i = 1 ; i <= bottom; i++)
  11.         cprintf("Press any key to save and restore these long lines"
  12.                 " of text in a narrow column\n\r");
  13.                             /* Now use gettext to save
  14.                             this text in a buffer */
  15.     bufsize = 2 * (bottom - top + 1) * (right - left + 1);
  16.     if((tbuffer = (char *) malloc(bufsize)) == NULL)
  17.     {
  18.         cputs("Error allocating buffer!");
  19.         exit(1);
  20.     }
  21.     if(!gettext(left, top, right, bottom, tbuffer))
  22.     {
  23.         cputs("Error saving text!");
  24.         exit(1);
  25.     }
  26.     getch();                /* wait for a keypress */
  27.                             /* Restore buffer using puttext
  28.                             in a narrow box */
  29.     if(!puttext(left, top + 11, right / 2, bottom * 2 + 11, tbuffer))
  30.         cputs("Error restoring text!");
  31.     getch();
  32. }